package com.study.talk.module.service.impl;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.study.talk.module.entity.InviteGroupRecord;
import com.study.talk.module.mapper.InviteGroupRecordMapper;
import com.study.talk.module.service.InviteGroupRecordService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author thor
 * @since 2023-12-18
 */
@Service
@Transactional
public class InviteGroupRecordServiceImpl extends ServiceImpl<InviteGroupRecordMapper, InviteGroupRecord> implements InviteGroupRecordService {

    @Resource
    private InviteGroupRecordMapper inviteGroupRecordMapper;

    @Override
    public void addInviteMember(Integer groupId, Integer inviteId, Integer userId) {
        InviteGroupRecord inviteGroupRecord = new InviteGroupRecord(groupId, inviteId, userId);
        inviteGroupRecordMapper.insert(inviteGroupRecord);
    }

    @Override
    public void removeInviteMember(Integer groupId, Integer inviteId, Integer userId) {
        inviteGroupRecordMapper.removeGroupUserInfo(groupId, inviteId, userId);
    }

    @Override
    public boolean queryHasInviteMember(Integer groupId, Integer inviteId, Integer userId) {
        return ObjectUtils.isNotNull(inviteGroupRecordMapper.queryHasMember(groupId, inviteId, userId));
    }
}